package com.zenithmind.article.pojo.vo;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.util.List;

import com.zenithmind.article.pojo.domain.Tag;
import com.zenithmind.article.pojo.domain.Category;

/**
 * 文章视图对象
 * 遵循单一职责原则：专注于文章展示数据
 * 遵循里氏替换原则：正确继承BaseVO
 */
@EqualsAndHashCode(callSuper = true)
@Data
@Schema(name = "文章视图对象", description = "文章展示数据对象")
public class ArticleVO extends BaseVO {

    @Schema(description = "文章标题")
    private String title;

    @Schema(description = "文章内容")
    private String content;

    @Schema(description = "文章摘要")
    private String summary;

    @Schema(description = "封面图片URL")
    private String coverImage;

    @Schema(description = "分类信息")
    private Category category;

    @Schema(description = "作者信息")
    private UserVO userVo;

    @Schema(description = "浏览量")
    private Integer viewCount;

    @Schema(description = "点赞数")
    private Integer likeCount;

    @Schema(description = "评论数")
    private Integer commentCount;

    @Schema(description = "文章状态码")
    private Integer status;

    @Schema(description = "是否置顶")
    private Boolean isTop;

    @Schema(description = "是否推荐")
    private Boolean isRecommend;

    @Schema(description = "标签列表")
    private List<Tag> tag;

    @Override
    public String getDisplayName() {
        return this.title;
    }

    @Override
    public String getStatusDescription() {
        if (status == null) return "未知";
        switch (status) {
            case 0: return "草稿";
            case 1: return "已发布";
            case 2: return "已删除";
            case 3: return "已归档";
            default: return "未知状态";
        }
    }

    /**
     * 检查文章是否已发布
     */
    public boolean isPublished() {
        return status != null && status == 1;
    }

    /**
     * 检查文章是否为草稿
     */
    public boolean isDraft() {
        return status != null && status == 0;
    }

    /**
     * 获取作者名称
     */
    public String getAuthorName() {
        return userVo != null ? userVo.getDisplayName() : "未知作者";
    }

    /**
     * 获取分类名称
     */
    public String getCategoryName() {
        return category != null ? category.getName() : "未分类";
    }
}
